/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ru.ssau.berlin.jsf.beans;

import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.model.SelectItem;
import ru.ssau.berlin.ejb.facade.UniFacadeLocal;
import ru.ssau.berlin.entity.AttributeType;


/**
 *
 * @author Пользователь
 */
public class AttributeTypeView {

    @EJB
    private UniFacadeLocal uniFacade;

    private List<AttributeType> attrTypes = null;
    private List<SelectItem> attrTypeItems = null;

    public List<SelectItem> getAttrTypeItems() {
        if (attrTypeItems == null) {
            List<AttributeType> types = getAttrTypes();  // for initialization, if not initialized
            attrTypeItems = new ArrayList<SelectItem>(types.size());
            for (AttributeType type : attrTypes) {
                attrTypeItems.add(new SelectItem(type, type.getName()));
            }
        }
        return attrTypeItems;
    }

    public void setAttrTypeItems(List<SelectItem> attrTypeItems) {
        this.attrTypeItems = attrTypeItems;
    }

    public List<AttributeType> getAttrTypes() {
        if (attrTypes == null) {
            attrTypes = uniFacade.findAttributeTypes();
        }
        return attrTypes;
    }

    public void setAttrTypes(List<AttributeType> attrTypes) {
        this.attrTypes = attrTypes;
    }
    
}
